﻿Imports System.Data.SqlClient


Public Class LoaiNhaBUS

    Public Shared Function GetAll() As List(Of LoaiNhaDTO)
        Dim listLoaiNha As List(Of LoaiNhaDTO)

        listLoaiNha = LoaiNhaDAO.GetAll()

        Return listLoaiNha
    End Function

    Public Shared Function SLLoaiNha() As Integer
        Dim SoLuong As Integer

        SoLuong = LoaiNhaDAO.SoLuongLoaiNha()

        Return SoLuong
    End Function
    

    Public Shared Sub Insert(ByVal loainha As LoaiNhaDTO)

        Dim para As SqlParameter = New SqlParameter("TenLoaiNha", SqlDbType.NVarChar)
        para.Direction = ParameterDirection.Input
        para.Value = loainha.strTenLoaiNha


        LoaiNhaDAO.Insert(para)
    End Sub
   

    Public Shared Sub delete_LoaiNha(ByVal maloainha As Integer)
        Dim parameters(1) As SqlParameter

        Dim para As SqlParameter = New SqlParameter("MaLoaiNha", SqlDbType.Int)
        para.Direction = ParameterDirection.Input
        para.Value = maloainha
        parameters(0) = para

        LoaiNhaDAO.Delete(para)
    End Sub
    Public Shared Sub Update(ByVal loainha As LoaiNhaDTO)


        Dim para As SqlParameter = New SqlParameter("MaLoaiNha", SqlDbType.Int)
        para.Direction = ParameterDirection.Input
        para.Value = loainha.iMaLoaiNha

        Dim para1 As SqlParameter = New SqlParameter("TenLoaiNha", SqlDbType.NVarChar)
        para1.Direction = ParameterDirection.Input
        para1.Value = loainha.strTenLoaiNha

        LoaiNhaDAO.Update(para, para1)
    End Sub
    
    Public Shared Function KiemTraDayDu(ByVal tenloainha As String)
        Dim kq As Boolean
        If Not tenloainha = "" Then

            kq = True
        Else
            kq = False
        End If

        Return kq
    End Function
End Class
